<?php
/**
 * common model file Created by PhpStorm.
 * User: wumengmeng
 * Date: 2019/09/03
 * Time: 15:20
 */

namespace HiCommon\Model;


class ShopModify extends Base
{

    protected $table = 'shop_modify';

    protected $guarded = [];

    //public $timestamps = false;






    /**
     * 获取图片可用链接
     *
     * @return array
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function getImgAttribute($value)
    {
        $arr_data = [
            'src'=>$value,
            'full_src'=>oss_full_url($value),
        ];
        return $arr_data;
    }


    /**
     * 获取图片可用链接
     *
     * @return array
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function getStatusAttribute($value)
    {
        switch ($value)
            {
                case 1:
                    $res = ['id'=>1,'name'=>'待审核'];
                    break;
                case 3:
                    $res = ['id'=>3,'name'=>'驳回申请'];
                    break;
                case 2:
                    $res = ['id'=>2,'name'=>'审核通过'];
                    break;
                default:
                    $res = ['id'=>-1,'name'=>'未知'];
            }
            return $res;

    }



    /**
     * 获取图片可用链接
     *
     * @return array
     * @author wumengmeng <wu_mengmeng@foxmail.com>
     */
    public function getLogoAttribute($value)
    {
        $arr_data = [
            'src'=>$value,
            'full_src'=>oss_full_url($value),
        ];
        return $arr_data;
    }


    //省
    public function province_name()
    {
        return $this->hasOne(Areas::class, 'id','province')
            ->select('id','name');
    }

    //市
    public function city_name()
    {
        return $this->hasOne(Areas::class, 'id','city')
            ->select('id','name','Lng','Lat');
    }

    //区
    public function area_name()
    {
        return $this->hasOne(Areas::class, 'id','area')
            ->select('id','name','mername');
    }


    //商店信息
    public function shop_info()
    {
        return $this->hasOne(Shop::class, 'id','shop_id');
    }


    //关联图片信息
    public function shop_modify_img()
    {
        return $this->hasMany(ShopModifyImg::class, 'shop_modify_id');
    }



}